<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Master;
class MasterController extends Controller
{
    //
    public function index(Master $master)
    {
        $masters = Master::orderBy('created_at', 'desc')->get();
        return view('champion/champion',compact('masters'));
    }
    public function admin(Master $master)
    {
        return view('master/index',compact('master'));
    }
    public function update(Master $master)
    {
        //验证
        $this->validate(request(), [
            'name' => 'required',
            'ement' => 'required',
        ]);
        //逻辑
        $master->name = request("name");
        $master->ement = request("ement");
        $master->save();
        //渲染
        return redirect('/champion');
    }
}
